import service from '../utils/index'

// 登录接口
export const loginApi = (data) => {
  return service({
    url: '/login',
    method: 'post',
    data
  })
}

export const MenulistApi = (data) => {
  return service({
    url: '/menus',
    method: 'get'
  })
}

export const userslist = (params) => {
  return service({
    url: '/users',
    method: 'get',
    params
    // query: data.query,
    // params: data.params
  })
}

export const userstate = (params) => {
  // console.log(params, '12321321312312');
  return service({

    // url: 'users/:uId/state/:type   ',
    url: `users/${params.id}/state/${params.mg_state}`,
    method: 'put'

    // query: data.query,
    // params: data.params
  })
}

export const addusers = (data) => {
  // console.log(params, '12321321312312');
  return service({

    url: 'users',
    method: 'post',
    data
  })
}

export const addeidtusers = (data) => {
  // console.log(data, '12321321312312');

  return service({
    url: `users/${data.id}`,
    method: 'put',
    data

  })
}

export const removeusers = (id) => {
  // console.log(id, '12321321312312');

  return service({
    url: `users/${id}`,
    method: 'delete'

  })
}

export const getrightslist = () => {
  // console.log(params, '12321321312312');

  return service({
    url: 'rights/list',
    method: 'get'

  })
}

export const getroleslist = () => {
  // console.log(params, '12321321312312');

  return service({
    url: 'roles',
    method: 'get'

  })
}

export const getrightlist = () => {
  // console.log(params, '12321321312312');

  return service({
    url: 'rights/tree',
    method: 'get'

  })
}

export const setrights = (params, id) => {
  // console.log(params, 'params');
  // console.log(id, 'id');

  return service({

    url: `/roles/${params}/rights`,
    method: 'post',
    data: {
      rids: id
    }

  })
}

export const getrolelist = () => {
  return service({

    url: 'roles',
    method: 'get'

  })
}

export const setuserrole = (userid, data) => {
  // console.log(data, '12321321312312');
  return service({
    url: `users/${userid}/role`,
    method: 'put',
    data: {
      rids: data
    }

  })
}
